home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 4.adf / 204inc_h.lzh / intuition / sghooks.h < prev   
C/C++ Source or Header  |  1991-03-14  |  7KB  |  192 lines

  1. #ifndef INTUITION_SGHOOKS_H
  2. #define INTUITION_SGHOOKS_H TRUE
  3. /*
  4. **  $Filename: intuition/sghooks.h $
  5. **  $Release: 2.04 $
  6. **  $Revision: 36.4 $
  7. **  $Date: 91/02/12 $
  8. **
  9. **  string gadget extensions and hooks
  10. **
  11. **  (C) Copyright 1985,1986,1987,1988,1989,1990 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. */
  14.  
  15. #ifndef EXEC_TYPES_H
  16. #include <exec/types.h>
  17. #endif
  18.  
  19. struct StringExtend {
  20.     /* display specifications    */
  21.     struct TextFont *Font;    /* must be an open Font (not TextAttr)    */
  22.     UBYTE    Pens[2];    /* color of text/backgroun        */
  23.     UBYTE    ActivePens[2];    /* colors when gadget is active        */
  24.  
  25.     /* edit specifications    */
  26.     ULONG    InitialModes;    /* initial mode flags, below        */
  27.     struct Hook *EditHook;    /* if non-NULL, must supply WorkBuffer    */
  28.     UBYTE    *WorkBuffer;    /* must be as large as StringInfo.Buffer*/
  29.  
  30.     ULONG    Reserved[4];    /* set to 0                */
  31. };
  32.  
  33. struct SGWork    {
  34.     /* set up when gadget is first activated    */
  35.     struct Gadget    *Gadget;    /* the contestant itself    */
  36.     struct StringInfo    *StringInfo;    /* easy access to sinfo        */
  37.     UBYTE        *WorkBuffer;    /* intuition's planned result    */
  38.     UBYTE        *PrevBuffer;    /* what was there before    */
  39.     ULONG        Modes;        /* current mode            */
  40.  
  41.     /* modified for each input event    */
  42.     struct InputEvent    *IEvent;    /* actual event: do not change    */
  43.     UWORD        Code;        /* character code, if one byte    */
  44.     WORD        BufferPos;    /* cursor position        */
  45.     WORD        NumChars;
  46.     ULONG        Actions;    /* what Intuition will do    */
  47.     LONG        LongInt;    /* temp storage for longint    */
  48.  
  49.     struct GadgetInfo    *GadgetInfo;    /* see cghooks.h        */
  50.     UWORD        EditOp;        /* from constants below        */
  51. };
  52.  
  53. /* SGWork.EditOp -
  54.  * These values indicate what basic type of operation the global
  55.  * editing hook has performed on the string before your gadget's custom
  56.  * editing hook gets called.  You do not have to be concerned with the
  57.  * value your custom hook leaves in the EditOp field, only if you
  58.  * write a global editing hook.
  59.  *
  60.  * For most of these general edit operations, you'll want to compare
  61.  * the BufferPos and NumChars of the StringInfo (before global editing)
  62.  * and SGWork (after global editing).
  63.  */
  64.  
  65. #define EO_NOOP        (0x0001)
  66.     /* did nothing                            */
  67. #define EO_DELBACKWARD    (0x0002)
  68.     /* deleted some chars (maybe 0).                */
  69. #define EO_DELFORWARD    (0x0003)
  70.     /* deleted some characters under and in front of the cursor    */
  71. #define EO_MOVECURSOR    (0x0004)
  72.     /* moved the cursor                        */
  73. #define EO_ENTER    (0x0005)
  74.     /* "enter" or "return" key, terminate                */
  75. #define EO_RESET    (0x0006)
  76.     /* current Intuition-style undo                    */
  77. #define EO_REPLACECHAR    (0x0007)
  78.     /* replaced one character and (maybe) advanced cursor        */
  79. #define EO_INSERTCHAR    (0x0008)
  80.     /* inserted one char into string or added one at end        */
  81. #define EO_BADFORMAT    (0x0009)
  82.     /* didn't like the text data, e.g., Bad LONGINT            */
  83. #define EO_BIGCHANGE    (0x000A)    /* unused by Intuition    */
  84.     /* complete or major change to the text, e.g. new string    */
  85. #define EO_UNDO        (0x000B)    /* unused by Intuition    */
  86.     /* some other style of undo                    */
  87. #define EO_CLEAR    (0x000C)
  88.     /* clear the string                        */
  89. #define EO_SPECIAL    (0x000D)    /* unused by Intuition    */
  90.     /* some operation that doesn't fit into the categories here    */
  91.  
  92.  
  93. /* Mode Flags definitions (ONLY first group allowed as InitialModes)    */
  94. #define SGM_REPLACE    (1L << 0)    /* replace mode            */
  95. /* please initialize StringInfo with in-range value of BufferPos
  96.  * if you are using SGM_REPLACE mode.
  97.  */
  98.  
  99. #define SGM_FIXEDFIELD    (1L << 1)    /* fixed length buffer        */
  100.                     /* always set SGM_REPLACE, too    */
  101. #define SGM_NOFILTER    (1L << 2)    /* don't filter control chars    */
  102.  
  103. /* SGM_EXITHELP is new for V37, and ignored by V36: */
  104. #define SGM_EXITHELP    (1L << 7)    /* exit with code = 0x5F if HELP hit */
  105.  
  106.  
  107. /* These Mode Flags are for internal use only                */
  108. #define SGM_NOCHANGE    (1L << 3)    /* no edit changes yet        */
  109. #define SGM_NOWORKB    (1L << 4)    /* Buffer == PrevBuffer        */
  110. #define SGM_CONTROL    (1L << 5)    /* control char escape mode    */
  111. #define SGM_LONGINT    (1L << 6)    /* an intuition longint gadget    */
  112.  
  113. /* String Gadget Action Flags (put in SGWork.Actions by EditHook)    */
  114. #define SGA_USE        (0x1L)    /* use contents of SGWork        */
  115. #define SGA_END        (0x2L)    /* terminate gadget, code in Code field    */
  116. #define SGA_BEEP    (0x4L)    /* flash the screen for the user    */
  117. #define SGA_REUSE    (0x8L)    /* reuse input event            */
  118. #define SGA_REDISPLAY    (0x10L)    /* gadget visuals changed        */
  119.  
  120. /* New for V37: */
  121. #define SGA_NEXTACTIVE    (0x20L)    /* Make next possible gadget active.    */
  122. #define SGA_PREVACTIVE    (0x40L)    /* Make previous possible gadget active.*/
  123.  
  124. /* function id for only existing custom string gadget edit hook    */
  125.  
  126. #define SGH_KEY        (1L)    /* process editing keystroke        */
  127. #define SGH_CLICK    (2L)    /* process mouse click cursor position    */
  128.  
  129. /* Here's a brief summary of how the custom string gadget edit hook works:
  130.  *    You provide a hook in StringInfo.Extension.EditHook.
  131.  *    The hook is called in the standard way with the 'object'
  132.  *    a pointer to SGWork, and the 'message' a pointer to a command
  133.  *    block, starting either with (longword) SGH_KEY, SGH_CLICK,
  134.  *    or something new.
  135.  *
  136.  *    You return 0 if you don't understand the command (SGH_KEY is
  137.  *    required and assumed).    Return non-zero if you implement the
  138.  *    command.
  139.  *
  140.  *   SGH_KEY:
  141.  *    There are no parameters following the command longword.
  142.  *
  143.  *    Intuition will put its idea of proper values in the SGWork
  144.  *    before calling you, and if you leave SGA_USE set in the
  145.  *    SGWork.Actions field, Intuition will use the values
  146.  *    found in SGWork fields WorkBuffer, NumChars, BufferPos,
  147.  *    and LongInt, copying the WorkBuffer back to the StringInfo
  148.  *    Buffer.
  149.  *
  150.  *    NOTE WELL: You may NOT change other SGWork fields.
  151.  *
  152.  *    If you clear SGA_USE, the string gadget will be unchanged.
  153.  *
  154.  *    If you set SGA_END, Intuition will terminate the activation
  155.  *    of the string gadget.  If you also set SGA_REUSE, Intuition
  156.  *    will reuse the input event after it deactivates your gadget.
  157.  *
  158.  *    In this case, Intuition will put the value found in SGWork.Code
  159.  *    into the IntuiMessage.Code field of the IDCMP_GADGETUP message it
  160.  *    sends to the application.
  161.  *
  162.  *    If you set SGA_BEEP, Intuition will call DisplayBeep(); use
  163.  *    this if the user has typed in error, or buffer is full.
  164.  *
  165.  *    Set SGA_REDISPLAY if the changes to the gadget warrant a
  166.  *    gadget redisplay.  Note: cursor movement requires a redisplay.
  167.  *
  168.  *    Starting in V37, you may set SGA_PREVACTIVE or SGA_NEXTACTIVE
  169.  *    when you set SGA_END.  This tells Intuition that you want
  170.  *    the next or previous gadget with GFLG_TABCYCLE to be activated.
  171.  *
  172.  *   SGH_CLICK:
  173.  *    This hook command is called when Intuition wants to position
  174.  *    the cursor in response to a mouse click in the string gadget.
  175.  *
  176.  *    Again, here are no parameters following the command longword.
  177.  *
  178.  *    This time, Intuition has already calculated the mouse position
  179.  *    character cell and put it in SGWork.BufferPos.    The previous
  180.  *    BufferPos value remains in the SGWork.StringInfo.BufferPos.
  181.  *
  182.  *    Intuition will again use the SGWork fields listed above for
  183.  *    SGH_KEY.  One restriction is that you are NOT allowed to set
  184.  *    SGA_END or SGA_REUSE for this command.    Intuition will not
  185.  *    stand for a gadget which goes inactive when you click in it.
  186.  *
  187.  *    You should always leave the SGA_REDISPLAY flag set, since Intuition
  188.  *    uses this processing when activating a string gadget.
  189.  */
  190.  
  191. #endif
  192.